<?php
declare (strict_types = 1);

namespace app\common\model;

use think\Model;
use think\response\Json;

/**
 * @mixin \think\Model
 */
class FreightPlate extends Base
{

    protected $name = 'freight_plate';
    public static function savepsot($param)
    {   parent::startTrans();
        try {
            $data['money']=$param['money'];
            $data['title']=$param['title'];
            $data['sort']=$param['sort'];
            $data['freight_ids']= implode(',',$param['freight_ids']);
            if(isset($param['id']) && $param['id']!=0){
                $data['id']=$param['id'];
                parent::update($data);
            }else{
                parent::create($data);
            }
            Freight::whereIn('id',$param['freight_ids'])->update(['money'=>$param['money']]);
            parent::commit();
            return ['code' => 1, 'msg' =>'操作成功！'];
        } catch (\Exception $e) {
            return ['code' => -1, 'msg' => $e->getMessage()];
        }
    }

}
